unit uERP_NextID;

interface

type
  TNextID = class

    {$REGION '<< Private >>'}

      private

        {$REGION '<< Atributes >>'}

          var m_Sequence: String;

        {$ENDREGION}

        {$REGION '<< Methods >>'}

          procedure SetSequence(const a_Value: String);

        {$ENDREGION}

    {$ENDREGION}

    {$REGION '<< Public >>'}

      public

        {$REGION '<< Methods >>'}

          constructor Create(const a_Sequence: String); overload;

          function GetNextID(): Int64;

        {$ENDREGION}

    {$ENDREGION}

  end;

implementation

uses uQuery, SysUtils;

{ TNextID }

constructor TNextID.Create(const a_Sequence: String);
begin
  Self.SetSequence(a_Sequence);
end;

function TNextID.GetNextID: Int64;
var
  Query: TMyQuery;
begin
  Query := TMyQuery.Create();
  try
    Result := Query.GetNextID(Self.m_Sequence);
  finally
    FreeAndNil(Query);
  end;
end;

procedure TNextID.SetSequence(const a_Value: String);
begin
  Self.m_Sequence := a_Value;
end;

end.
